package com.niit.session17.set;

import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class HashSetDemo2 {
	public static <E> void main(String[] args) {
		Student student4 = new Student("赵六",18);
		Student student1 = new Student("张三",19);
		Student student2 = new Student("李四",21);
		Student student3 = new Student("王五",22);
//		集合里也可以装引用数据类型
		Set<Student> hashSet = new HashSet<>();
		hashSet.add(student1);
		hashSet.add(student2);
		hashSet.add(student3);
		hashSet.add(student4);
		System.out.println(hashSet);
//		如果要排序，使用TreeSet
		Set<Student> treeSet = new TreeSet<>();
		treeSet.add(student1);
		treeSet.add(student2);
		treeSet.add(student3);
		treeSet.add(student4);
		System.out.println("---------排序-------------");
		System.out.println(treeSet);
		
	}

}
